package com.yuhanginfo.modules.sys.service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yuhanginfo.common.service.CrudService;
import com.yuhanginfo.common.utils.StringUtils;
import com.yuhanginfo.modules.sys.entity.Announcement;
import com.yuhanginfo.modules.sys.dao.AnnouncementDao;
/**
 * 公告信息Service
 * @author Y.j
 * @version 2017-09-13
 */
@Service
@Transactional(readOnly = true)
public class AnnouncementService extends CrudService<AnnouncementDao, Announcement> {


	
	@Transactional(readOnly = false)
	public void updateStatus(Announcement announcement) {
		if(announcement.getStatus()!=null&&announcement.getStatus()==1) {
			announcement.setStatus(0);
		}else {
			announcement.setStatus(1);
		}
		super.save(announcement);
	}
	
	@Transactional(readOnly = false)
	public void save(Announcement announcement) {
		if (StringUtils.isNotBlank(announcement.getId())){//保存则改变状态为未发布
			announcement.setStatus(0);
		}
		super.save(announcement);
	}
	
	@Transactional(readOnly = false)
	public void delete(Announcement announcement) {
		super.delete(announcement);
	}
	
}